#!/bin/sh
. "$(dirname "$0")/_/husky.sh"


# 获取当前分支
current_branch=$(git rev-parse --abbrev-ref HEAD)

echo -e "\033[33m -------------------  当前分支: $current_branch 正在对提交的代码执行commit操作 -------------------- \033[0m"

# 检查是否有待提交的文件
if [ -z "$(git diff --cached --name-only)" ]; then
  echo "暂存区域没有文件"
  exit 1
fi

npx --no-install lint-staged

# 添加格式化后的文件到暂存区
git add $(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx|json|css|scss|md)$')



echo -e "\033[33m -------------------  代码校验通过准备提交 ✅ -------------------- \033[0m"
exit 0

